﻿#pragma once

#include <xy/ais/point.h>
#include <xy/geom/manifold.h>

namespace xy
{

namespace ais
{

class curve : public object
{
  public:
    /**
     * @brief 指针构造
     *
     * @param[in] curve
     */
    explicit curve(std::shared_ptr<geom::curve<3>> curve);

    /**
     * @brief 采样
     *
     * @param[in] num
     * @return std::vector<geom::vec3f>
     */
    virtual std::vector<geom::vec3f> sample(std::size_t num) const;

    /**
     * @brief 获得曲线
     *
     * @return std::shared_ptr<geom::curve<3>>
     */
    std::shared_ptr<geom::curve<3>> cur() const;

    /**
     * @brief 碰撞检测接口
     *
     * @param[in] msg
     * @return true
     * @return false
     */
    bool collision(msg_mouse *msg) override;

    /**
     * @brief 初始化消息
     *
     * @param[in] msg
     */
    void visit(msg_init *msg) override;

  protected:
    std::shared_ptr<geom::curve<3>> m_curve;
};

class curve_auxiliary : public curve
{
  public:
    /**
     * @brief 辅助曲线是由一组辅助点组成的曲线
     *
     */
    explicit curve_auxiliary();

    /**
     * @brief 添加辅助点
     *
     * @param[in] pnt
     */
    void add_point(std::shared_ptr<point_auxiliary> pnt);

    /**
     * @brief 曲线采样
     *
     * @param[in] num
     * @return std::vector<geom::vec3f>
     */
    std::vector<geom::vec3f> sample(std::size_t num) const override;

    /**
     * @brief 鼠标消息
     *
     * @param[in] msg
     */
    void visit(msg_mouse *msg) override;

  protected:
    std::vector<std::shared_ptr<point_auxiliary>> m_points;
};

} // namespace ais

} // namespace xy
